home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / AEWIN100.ARJ / VIEWPORT.H < prev    next >
C/C++ Source or Header  |  1990-12-27  |  2KB  |  77 lines

  1. /**********************************************************************
  2.  *  
  3.  *  NAME:           viewport.h
  4.  *  
  5.  *  DESCRIPTION:    the "active" part of a window
  6.  *  
  7.  *  copyright (c) 1990 J. Alan Eldridge
  8.  * 
  9.  *  M O D I F I C A T I O N   H I S T O R Y
  10.  *
  11.  *  when        who                 what
  12.  *  -------------------------------------------------------------------
  13.  *  11/29/90    J. Alan Eldridge    created
  14.  *  
  15.  *********************************************************************/
  16.  
  17. #ifndef __VIEWPORT_H
  18. #define __VIEWPORT_H
  19.  
  20. class viewport {
  21.  
  22. protected:
  23.  
  24.     int yUL, xUL, yLR, xLR;
  25.  
  26. public:    
  27.     
  28.     //  get port boundaries
  29.     
  30.     void getport(int &yul, int &xul, int &ylr, int &xlr)
  31.         { yul = yUL; xul = xUL; ylr = yLR; xlr = xLR; }
  32.     void getport(int *box)
  33.         { box[0] = yUL; box[1] = xUL; box[2] = yLR; box[3] = xLR; }
  34.     viewport    &getport()
  35.         { return *this; }
  36.             
  37.     //  set port boundaries
  38.     //  these are virtual because windows are derived from
  39.     //  this class, and they need to do more work when
  40.     //  changing the viewport
  41.  
  42.     virtual void setport(int yul, int xul, int ylr, int xlr)
  43.         { yUL = yul; xUL = xul; yLR = ylr; xLR = xlr; }
  44.     virtual void setport(int *box)
  45.         { viewport::setport(box[0],box[1],box[2],box[3]); }
  46.     virtual void setport(viewport &vp)
  47.         { *this = vp; }
  48.         
  49.     //  get size
  50.     
  51.     int portrows()
  52.         { return yLR - yUL + 1; }
  53.     int portcols()
  54.         { return xLR - xUL + 1; }
  55.     
  56.     //  constructors (no destructor)
  57.     
  58.     viewport()
  59.         { setport(0, 0, -1, -1); }
  60.     viewport(int yul, int xul, int ylr, int xlr)
  61.         { setport(yul, xul, ylr, xlr); }
  62.     viewport(int *box) 
  63.         { setport(box); }
  64.  
  65.     //  is it set to something reasonable?
  66.     
  67.     int isempty()
  68.         { return yLR < yUL || xLR < xUL; }
  69.         
  70.     //  check location of pointing device
  71.  
  72.     int intheport(int &y, int &x);
  73. };
  74.  
  75.  
  76. #endif
  77.